package com.spic.job.api.factory;

import com.spic.common.core.domain.R;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.job.api.RemoteGuardLeadersignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

/**
 * @author 290512
 * @create 2021-11-03 20:10
 */
@Slf4j
@Component
public class RemoteGuardLeadersignFallbackFactory implements FallbackFactory<RemoteGuardLeadersignService> {
    @Override
    public RemoteGuardLeadersignService create(Throwable cause) {
        return new RemoteGuardLeadersignService() {
            @Override
            public R<List<HashMap<String, Object>>> selectSignCount() {
                return R.fail("获取定时任务失败:" + cause.getMessage());
            }

            @Override
            public AjaxResult materialNameList() {
                return AjaxResult.error("获取定时任务失败");
            }

            @Override
            public AjaxResult materialNameLists() {
                return AjaxResult.error("获取定时任务失败");
            }

            @Override
            public AjaxResult notice() {
                return AjaxResult.error("获取定时任务失败");
            }

            @Override
            public AjaxResult weighAlarm() {
                return AjaxResult.error("称重告警任务发送失败");
            }

            @Override
            public void markViolationImage() {
                log.error("违章图片加水印失败");
            }


        };
    }
}
